<?php
class TableSkinService {
    private static $instance;

    public static function get() {
        if (!self::$instance) {
            self::$instance = new TableSkinService();
        }
        return self::$instance;
    }

    protected function __construct() {
    }

    /**
     * 玩家桌子皮肤数据
     * @param $userId
     * @param $reqTime
     * @return array
     * @throws SzException
     */
    public function info($userId,$reqTime) {
        /**
         * 获取玩家数据
         * @var $tableSkinList TableSkinVoList
         * @var $tableSkin TableSkinVo
         */
        $tableSkinList = SzPersister::get()->getVoList($userId, GameConst::ORM_NAME_TABLE_SKIN);
        if($tableSkinList->getListCount() == 0){
            //创建默认皮肤

            //设置当前正在使用皮肤字段


        }

        $tableSkinArr = $tableSkinList->toArray();

        return $tableSkinArr;
    }

    /**
     * 更换玩家桌子皮肤
     * @param $userId
     * @param $skinId
     * @param $reqTime
     * @return array
     * @throws SzException
     */
    public function change($userId,$skinId,$reqTime) {
        /**
         * 获取玩家数据
         * @var $tableSkinList TableSkinVoList
         * @var $tableSkin TableSkinVo
         */
        $tableSkinList = SzPersister::get()->getVoList($userId, GameConst::ORM_NAME_TABLE_SKIN)->toArray();

        if (empty($tradeItemArr)){
            return array();
        }

        foreach ($tradeItemArr as $position=>$data){
            unset($data['userId']);
            unset($data['times']);
            unset($data['buyShelf']);
            unset($data['shareTimes']);
            unset($data['createTime']);
            unset($data['updateTime']);
            $tradeItemArr[$position] = $data;
        }

        return $tradeItemArr;
    }





}